﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JobDemo01.Job
{
    static class Marker
    {
        public static void Draw(ImageData img, double dx, double dy)
        {
            var (width, height, b, _) = img;
            int centerX = (int)(width / 2 + dx);
            int centerY = (int)(height / 2 + dy);
            int crossSize = Math.Min(width, height) / 25;
            int crossThickness = 2;
            for (int y = centerY - crossThickness; y <= centerY + crossThickness; y++)
            {
                if (y < 0 || y >= height) continue;
                for (int x = centerX - crossSize; x < centerX + crossSize; x++)
                {
                    if (x < 0 || x >= width) continue;
                    int index = y * width + x;
                    if (index < b.Length)
                    {
                        b[index] = 255;
                    }
                }
            }

            for (int x = centerX - crossThickness; x <= centerX + crossThickness; x++)
            {
                if (x < 0 || x >= width) continue;
                for (int y = centerY - crossSize; y < centerY + crossSize; y++)
                {
                    if (y < 0 || y >= height) continue;
                    int index = y * width + x;
                    if (index < b.Length)
                    {
                        b[index] = 255;
                    }
                }
            }
        }
    }
}
